﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Snake
{
    class SnakeComponent : IGameComponent//实现GameComponent接口
    {
        public Point Position { get; set; }
        public Size Size { get; set; }
        public Brush Color { get; set; }
        /// <summary>
        /// 创建SnakeComponent的新实例
        /// </summary>
        /// <param name="position"></param>
        /// <param name="size"></param>
        /// <param name="color"></param>
        public SnakeComponent(Point position,Size size,Brush color)
        {
            Position = position;
            Size = size;
            Color = color;
        }
        public void Show(Graphics g)
        {
            g.FillRectangle(Color, new Rectangle(new Point(Position.X * Size.Width, Position.Y * Size.Height), Size));
        }
    }

    class Food : IGameComponent//实现GameComponent接口
    {
        public Point Position { get; set; }
        public Size Size { get; set; }
        public Brush Color { get; set; }
        public Food(Point position, Size size, Brush color)
        {
            Position = position;
            Size = size;
            Color = color;
        }
        public void Show(Graphics g)
        {
            g.FillRectangle(Color, new Rectangle(new Point(Position.X * Size.Width, Position.Y * Size.Height), Size));
        }
    }

    class Wall : IGameComponent//实现GameComponent接口
    {
        public Point Position { get; set; }
        public Size Size { get; set; }
        public Brush Color { get; set; }
        public Wall(Point position, Size size, Brush color)
        {
            Position = position;
            Size = size;
            Color = color;
        }
        public void Show(Graphics g)
        {
            g.FillRectangle(Color, new Rectangle(new Point(Position.X * Size.Width, Position.Y * Size.Height), Size));
        }
    }
}
